<?php

namespace app\api\controller;

use think\Db;

/**
 * @title 院校详情
 * @description 接口说明
 * @group api
 * @header name:authorization require:1 default: desc:登陆的token
 */
class SchoolDetail extends Base
{
    /**
     * @title 院校详情-信息获取(get)
     * @description 接口说明
     * @author wang
     * @url /api/SchoolDetail
     * @method GET
     *
     * @param name:id type:int require:1 default:1 other: desc:专业id


     * @return size:每页最大数，默认20，可由前端传递参数决定 page参数返回值，
     * @return page:当前页，page参数返回值，
     * @return count:总记录数， page参数返回值，
     *
     * @return data:消息列表,有page参数则返回值list，list是一个数组@
     * @list id:门类的id city:门类的名字 create_time:创建时间 num:学科数量
     *

     */
    public function gets()
    {

        $id= input('get.id');

        $data['speciality'] =model('speciality')->where('id',$id)->find();
        $data['school'] =model('school')->where('id', $data['speciality']['school_id'])->find() ;
        $data['province'] =model('province')->where('id', $data['school']['province_id'])->find() ;
        $data['school_detail'] =model('school_detail')->where('speciality_id', $id)->find();

//        $data = Db::view('speciality', 'id,name')
//            ->view('school', 'tags,photo', 'school.id=speciality.school_id', 'LEFT')
//            ->view('school_detail', 'speciality_max_score,speciality_min_score', 'speciality.id=school_detail.speciality_id', 'LEFT')
//            ->view('direction', ['name'=>'direction_name'], 'speciality.id=direction.id', 'LEFT')
//            ->where($map)
//            ->select();


        $this->responseSuccess($data);


    }
    /**
     * @title 研友互助获取(get)
     * @description 接口说明
     * @author wang
     * @url /api/SchoolDetail
     * @method GET
     * @header name:Accept require:1 default:application/json,version=2 desc:获取的版本
     * @param name:id type:int require:1 default:1 other: desc:专业id


     * @return community:返回的研友互助QQ群账号，
     *
     */
    public function gets_v2()
    {
        $id= input('get.id');
        $data =Db::table('school_detail')->field('community')->where('speciality_id', $id)->find();
        $this->responseSuccess($data);
    }

    protected function _searchPage(&$where)
    {
        $id = input('get.id');
        if (!empty($id)) {
            $where[] = ["id", '=', $id];
        }
        $speciality = input('get.speciality_id');
        if (!empty($speciality)) {
            $where[] = ["speciality_id", '=', $speciality];
        }

    }
}
